import 'package:shelf_route/shelf_route.dart' as shelf_route;
import 'package:shelf/shelf.dart' as shelf;

import 'package:loyhd/src/htmldoc/generator.dart';
import 'package:loyhd/src/htmldoc/impl/html_generator.dart';
import 'package:loyhd/config.dart';

import 'dart:async';

shelf_route.Router _router;

Future<shelf_route.Router> initRouter(Generator generator) async {
  if(_router != null) {
    return _router;
  }

  _router = shelf_route.router();
  _router.get('/',
      (_) => new shelf.Response.ok(
          generator.generate(PAGE_INDEX.INDEX),
          headers: {'content-type':'text/html;charset=utf-8'}));
  return _router;
}

Future<Generator> initGenerator() => HtmlGenerator.create();
